﻿using System;
using SilenthinkContract.Component;
using SilenthinkCommon.Components;

namespace Web.Helpers
{
    public static class WebHelper
    {
        public static string GetStaticJs(string fileName)
        {
            return string.Format("{0}/javascripts/{1}.js", WebSite.Static, fileName);
        }
        public static string GetStaticCss(string fileName)
        {
            return string.Format("{0}/stylesheets/{1}.css", WebSite.Static, fileName);
        }

        public static string GetCartUrl(Guid id, int qty = 0, int max = int.MaxValue)
        {
            if (qty > 0)
            {
                if (qty > max)
                {
                    return string.Format("/cart/?id={0}&qty={1}", id, qty - 1);
                }
                return string.Format("/cart/?id={0}&qty={1}", id, qty);
            }
            return string.Format("/cart/?id={0}&opt=1", id);
        }

        public static string GetAvatarUrl(long userId, AvatarSize avatarSize = AvatarSize.Big)
        {
            return string.Format("{0}/avatar/avatar.{1}.{2}.jpg", "http://my.silenthink.com", userId, avatarSize.GetSize());
        }

    }
}